home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / Portable Patmos / src / portable kernel / mac / math.c < prev    next >
Encoding:
Text File  |  1994-11-20  |  774 b   |  43 lines  |  [TEXT/KAHL]

  1. /*   modf() returns the fractional part of value and  stores  the
  2.      integral  part  indirectly  through iptr.  Thus the argument
  3.      value and the returned values modf() and *iptr satisfy
  4.  
  5.           (*iptr + modf) == value
  6.  
  7.      and both results have the same sign as value.   The  defini-
  8.      tion  of modf() varies among UNIX system implementations, so
  9.      avoid modf() in portable code.
  10. */
  11.  
  12. double modf(double value, double *iptr)
  13.     {
  14.     long x = (int) value;
  15.     if (x >= 0)
  16.         {
  17.         if (value < (double)x) x--;
  18.         }
  19.     else
  20.         {
  21.         if (value > (double)x) x++;
  22.         }
  23.     *iptr = x;
  24.     return value - *iptr;
  25.     }
  26.  
  27. int isinf(double x)
  28.     {
  29.     return 0;
  30.     }
  31.     
  32. int isnan(double x)
  33.     {
  34.     return 0;
  35.     }
  36.  
  37. double ldexp(double x, int n)
  38.     {
  39.     while (n-- > 0) x *= 2;
  40.     while (++n < 0) x /= 2;
  41.     return x;
  42.     }
  43.